<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function wait(n) {
            return new Promise((res, rej) => {
                setTimeout(() => {
                    res('等待了' + n + '毫秒')
                }, n)
            })
        }
        Promise.all([wait(1000), wait(2000), wait(3000)]).then(res => console.log(res))


        function resolve(data) {
            return new Promise((res) => {
                res(data)
            })
        }

        resolve('直接注册微任务1').then(console.log)
        Promise.resolve('直接注册微任务2').then(console.log)
        setTimeout(() => {
            console.log('宏任务来了')
            resolve('直接注册微任务3').then(console.log)
            Promise.resolve('直接注册微任务4').then(console.log)
            console.log('这个宏任务又结束了')
        })
        console.log('当前宏任务完成了')
    </script>
</body>

</html>